<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>搜索结果</title>
    <style>
        body{font-family: system-ui, -apple-system, Segoe UI, Roboto, PingFang SC, Microsoft YaHei, sans-serif;background:#fff;color:#111827;margin:0}
        .container{max-width:1000px;margin:0 auto;padding:1.5rem}
        .search{display:flex;gap:.5rem;margin-bottom:1rem}
        input[type=text]{flex:1;padding:.6rem .75rem;border:1px solid #e5e7eb;border-radius:.5rem}
        .btn{padding:.6rem 1rem;border:none;background:#2563eb;color:#fff;border-radius:.5rem}
        .item{border:1px solid #e5e7eb;border-radius:.5rem;padding:1rem;margin:.75rem 0}
        .item h3{margin:.2rem 0}
        .meta{color:#6b7280;font-size:.9rem;margin-bottom:.4rem}
        a.read{color:#2563eb;text-decoration:none}
    </style>
</head>
<body>
<div class="container">
    <form class="search" method="get" th:action="@{/search}">
        <input type="text" name="q" th:value="${q}" placeholder="输入关键词">
        <button class="btn" type="submit">搜索</button>
    </form>

    <div th:if="${page != null}">
        <div th:text="${'共 ' + page.totalElements + ' 条结果'}" class="meta"></div>
        <div th:each="it : ${page.content}" class="item">
            <h3>
                <a th:href="@{'/article/' + ${it.id}}" th:text="${it.title}"></a>
            </h3>
            <div class="meta">
                <span th:text="${it.category}"></span>
                ·
                <span th:text="${#temporals.format(it.updatedAt, 'yyyy-MM-dd HH:mm')}"></span>
            </div>
            <p th:text="${#strings.abbreviate(it.content, 160)}"></p>
            <a class="read" th:href="@{'/article/' + ${it.id}}">阅读全文 →</a>
        </div>
    </div>
</div>
</body>
</html>
